﻿using System;
using System.IO;

namespace SharePoint.Orm.TestHelpers {
    public static class PathHelpers {
        public static string GetSolutionDirectory() {
            string dir = Path.GetFullPath(".");
            while (true) {
                string checkFile = Path.Combine(dir, "sp-orm.sln");
                if (File.Exists(checkFile)) {
                    return dir;
                }

                DirectoryInfo parentDir = Directory.GetParent(dir);
                if (parentDir == null) {
                    throw new Exception("Could not find solution directory.");
                }
                dir = parentDir.FullName;
            }
        }
    }
}
